package reflex.test;


import org.apache.commons.lang3.StringUtils;

import java.lang.reflect.Field;

public class ObjUtil {

    public static void fieldNull(Object object) throws IllegalAccessException {
        Field[] fields = oConvertUtils.getAllFields(object);

        for (Field field : fields) {

            field.setAccessible(true);
            System.out.println(field.getType().getName());
            switch (field.getType().getName()) {
                case "java.lang.String" :
                    if (StringUtils.isEmpty((String)field.get(object)) ) {
                        field.set(object,null);
                    }
                break;
                case "java.lang.Integer" :
                    if (field.get(object) != null ){
                        if (0  ==  (Integer) field.get(object)  ) {
                            field.set(object,null);
                        }
                    }

                break;
            }
            }
        }
}
